home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-06-18 | 1.1 KB | 52 lines | [TEXT/ttxt] |
- //-------------------------------------------------------------------//
-
- // Syntax: toeplitz ( C )
- // toeplitz ( C , R )
-
- // Description:
-
- // The toeplitz function returns a non-symmetric Toeplitz matrix
- // having C as its first column and R as its first row. `toeplitz(C)'
- // is a symmetric (or Hermitian) Toeplitz matrix.
-
- // See also hankel.r
- //-------------------------------------------------------------------//
-
- // dependencies
-
- rfile flipud
-
- toeplitz = function ( c , r )
- {
- local(c, r, nc, h, j, nr);
-
- if (class(c) != "num") { error ("toeplitz: Inputs must be numeric"); }
-
- c = c[:];
- nc = length (c);
-
- if (!exist (r)) {
- r = c;
- else
- if (class(r) != "num") { error ("toeplitz: Inputs must be numeric"); }
- if (length (c) != length (r))
- {
- error ("toeplitz: Inputs must have the same length");
- }
- r = r[:];
- if (c[1] != r[1])
- {
- error ("toeplitz: First element of row must match first element of column");
- }
- }
-
- r = flipud (r);
- h = zeros (nc, nc);
- h[;1] = c;
- for (j in 2:nc)
- {
- h[;j] = [r[nc-j+1:nc-1]; c[1:nc-j+1]];
- }
- return h;
- };
-